aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/(profile)/+layout.server.js
blob: a508de925485eaafb752c007f2c91a71b2d31bfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { get } from "$lib/utils";

export async function load({ parent }) {
  let { subject, user } = await parent();

  subject.follows = [];
  subject.followers = [];

  try {
    subject.follows = await get(`/${subject.pubkey}/follows`);
  } catch (e) {
    console.log("problem fetching follows", e);
  }

  try {
    subject.followers = await get(`/${subject.pubkey}/followers`);
  } catch (e) {
    console.log("problem fetching followers", e);
  }

  if (user) {
    user.follows = await get(`/${user.pubkey}/follows?tagsonly=true`);
  }

  return { subject, user };
}